from math import log

"""
李老师的lucky number 是3，5和7，他爱屋及乌，
    还把所有质因数只有3，5，7的数字也认定为lucky number，
    比如9, 15, 21, 25等等。
    请聪明的你帮忙算一算小于等于x的lucky number有多少个？
    输入数据
        一个正整数x，3 =< x <= 1000000000000
    输出数据
        小于等于x的lucky number的个数。
    样例输入
        49
    样例输出
        11
"""


def lucky_numbers(n):
    count = 0
    for i in range(3, n + 1):
        rest = i
        while rest % 7 == 0:
            rest /= 7
        while rest % 5 == 0:
            rest /= 5
        while rest % 3 == 0:
            rest /= 3
        if rest == 1:
            count += 1
    return count


def lucky_numbers2(n):
    count = 0
    for a in range(int(log(n, 3)) + 1):
        for b in range(int(log(n, 5)) + 1):
            for c in range(int(log(n, 7)) + 1):
                number = 3**a * 5**b * 7**c
                if number <= n:
                    count += 1
    count -= 1
    return count


def lucky_numbers3(n):
    count = 0
    for a in range(int(log(n, 3)) + 1):
        for b in range(int(log(n / 3**a, 5)) + 1):
            for c in range(int(log(n / (3**a * 5**b), 7)) + 1):
                count += 1
    count -= 1
    return count


functions = [lucky_numbers, lucky_numbers2, lucky_numbers3]
n = int(input("Enter an integer: "))
for function in functions:
    print(function(n))
